#ifndef _LOG_H_
#define _LOG_H_

#include <stdio.h>

enum LOG_LEVEL {
    LOG_NULL,
    LOG_FATAL,
    LOG_INFO,
    LOG_DETAIL,
    LOG_DEBUG,
    LOG_ALL,
};

enum LOG_MODE {
    MODE_NULL,
    MODE_FILE_SIZE_LIMITED,
    MODE_FILE_HANDLER,
};

//  set log level to level.
//  returns the previouse level.
//  the default level is LOG_NULL.
int log_set_level(int level);

//  returns the current level.
int log_get_level();

//  set log mode to mode.
//  @param mode the mode
//  @param file the file handler to write log into, NULL if not used
//  @param file_name_prefix the file name prefix for the files to write log into, NULL if not used
//  @param file_size_limit the limitation to the log file, at which a new file should be created, 0 if not used
//  returns the previouse mode.
//  the default mode is MODE_NULL.
int log_set_mode(int mode, FILE* file, const char* file_name_prefix, int file_size_limit);

//  returns the current mode.
int log_get_mode();

//  write a message into the output device
//  a timestamp is to be added to the message, formated as:
//  2019-11-02 12:03:23 - the message
//  the time showed here is UTC time.
//  returns the number of characters written to the device, 
//  including the \n character(s).
int log_write(int level, const char* format, ...);

//  finish and close the log output.
void log_close();

#endif